import { maintenanceHttp } from '/@/utils/http/axios';
import {
  CceClusterInfoParam,
  CceClusterItem,
  CceDetailItem,
  CceHostItem,
  CceInfoItem,
  CceInfoParam,
  DcsItem,
  DcsParam,
  GenealInfoItem,
  RdsItem,
  RdsParam,
} from '/@/api/maintenance-center/cloud-service-monitor/model/cloudServiceMonitorModel';

enum Api {
  GET_CCE_CLUSTER_LIST = '/v1/maintenance/cloudresource/getCceClusterList',
  GET_CCE_CLUSTER = '/v1/maintenance/cloudresource/getCceCluster',
  GET_ONE_CCE_CLUSTER = '/v1/maintenance/cloudresource/getOneCceCluster',
  GET_CCE_HOST = '/v1/maintenance/cloudresource/getCceHostList',
  GET_CCE_INFO = '/v1/maintenance/cloudresource/getCceHostSeries',
  GET_RDS_LIST = '/v1/maintenance/cloudresource/getRdsList',
  GET_DCS_LIST = '/v1/maintenance/cloudresource/getDcsList',
  GET_RDS_METRIC_DATA = '/v1/maintenance/cloudresource/getRdsMetricData',
  GET_DCS_METRIC_DATA = '/v1/maintenance/cloudresource/getDcsMetricData',
}

export const getCceClusterInfo = (params: CceClusterInfoParam) => {
  return maintenanceHttp.get<CceInfoItem>({ url: Api.GET_CCE_CLUSTER, params });
};

export const getCceHostInfo = () => {
  return maintenanceHttp.get<CceHostItem[]>({ url: Api.GET_CCE_HOST });
};

export const getCceHostService = (params: CceInfoParam) => {
  return maintenanceHttp.get<CceDetailItem>({ url: Api.GET_CCE_INFO, params });
};

export const getRdsList = () => {
  const rdsList = maintenanceHttp.get<RdsItem[]>({ url: Api.GET_RDS_LIST });
  return rdsList;
};

export const getDcsList = () => {
  return maintenanceHttp.get<DcsItem[]>({ url: Api.GET_DCS_LIST });
};

export const getCceClusterList = () => {
  return maintenanceHttp.get<CceClusterItem[]>({
    url: Api.GET_CCE_CLUSTER_LIST,
  });
};

export const getOneCceClusterList = async () => {
  const res = await maintenanceHttp.get<CceClusterItem>({
    url: Api.GET_CCE_CLUSTER_LIST,
  });
  return res;
};

export const getRdsInfo = async (params: RdsParam) => {
  const res = await maintenanceHttp.get<GenealInfoItem>({
    url: Api.GET_RDS_METRIC_DATA,
    params,
  });
  return res;
};

export const getDcsInfo = async (params: DcsParam) => {
  const res = await maintenanceHttp.get<GenealInfoItem>({
    url: Api.GET_DCS_METRIC_DATA,
    params,
  });
  return res;
};
